package 字符串;

/*
 * String当中与转换相关的常用方法有
 * public    char[] toCharArray();   将当前字符串拆分为字符数组作为返回值
 * public    byte[] getBytes();      获得当前字符串的字节数组
 * public    String replace(CharSequence oldString,CharSequence newString)
 * 将所有出现的老字符串替换成为新的字符串，返回替换之后的结果新字符串
 *
 * */
public class 字符串转换 {
    public static void main(String[] args) {

        char[] ch = "hello".toCharArray();
        System.out.println(ch[0]);
        System.out.println(ch.length);
        System.out.println("****************************");

        //转换成字节数组
        byte[] b = "abcd".getBytes();
        System.out.println(b[0]);
        System.out.println(b.length);
        System.out.println("*****************************");

        String str1 = "ababababababbababababa";
        String str2 = str1.replace("b", "a");
        System.out.println(str2);
    }
}
